package com.example.demo.testOne;

import cn.hutool.json.JSONUtil;
import com.example.demo.pojo.dto.ScoreLineDTO;

import java.util.Map;

/**
 * @author lilinchun
 * @date 2023/6/1 0001 09:49
 */
public class demo2 {


    // json解析
        public static void main(String[] args) {
//            String information = "{\"姓名\":\"醉驾\",\"电话\":\"15333333333\",\"工作单位\":\"回家吗\",\"会议类型\":\"审稿会\",\"科目\":\"语文\",\"是否住宿\":\"否\",\"性别\":\"女\"}";
//            Map<String, String> jsonObject = (Map<String, String>) JSONUtil.parse(information);
//            jsonObject.keySet().forEach(x -> {
//                System.out.println("key:" + x + "   value:" + jsonObject.get(x));
//            });
//
//            String str = "[{\"name\": \"姓名\",\"type\": \"fill\",\"required\": true,\"attribute\": \"text\",\"length\": \"10\"},{\"name\": \"工作单位\",\"type\": \"fill\",\"required\": true,\"attribute\": \"text\",\"length\": \"20\"},{\"name\": \"联系电话\",\"type\": \"fill\",\"required\": true,\"attribute\": \"number\",\"length\": \"20\"},{\"name\": \"会议类型\",\"type\": \"select\",\"required\": true,\"attribute\": \"single\",\"options\": [\"考务会\",\"审稿会\"]},{\"name\": \"科目\",\"type\": \"select\",\"required\": false,\"attribute\": \"single\",\"options\": [\"语文\", \"数学\", \"英语\",\"物理\",\"历史\",\"化学\",\"地理\",\"政治\",\"生物\"]},{\"name\": \"是否住宿\",\"type\": \"select\",\"required\": true,\"attribute\": \"single\",\"options\": [\"是\", \"否\"]},{\"name\": \"性别\",\"type\": \"select\",\"required\": false,\"attribute\": \"single\",\"options\": [\"男\", \"女\"]}]";
//            List<Object> list1 = JSONUtil.parseArray(str);
//            List<String>  names=new ArrayList<>();
//            for (Object o:list1){
//                   Map<String ,String > map= (Map<String, String>) JSONUtil.parse(o);
//                   names.add(map.get("name"));
//            }
//            System.out.println(names);

            String str1="{\"phySpecialBatch\":476.5,\"phyUndergraduateBatch\":411,\"phySpecialistBatch\":180,\"hisSpecialBatch\":493,\"hisUndergraduateBatch\":415,\"hisSpecialistBatch\":180}";
            Map<String, String> map = (Map<String, String>) JSONUtil.parse(str1);
            ScoreLineDTO scoreLineDTO = new ScoreLineDTO();
            scoreLineDTO.setPhySpecialBatch(String.valueOf(map.get("phySpecialBatch")));
            scoreLineDTO.setPhyUndergraduateBatch(String.valueOf(map.get("phyUndergraduateBatch")));
            scoreLineDTO.setPhySpecialistBatch(String.valueOf(map.get("phySpecialistBatch")));
            scoreLineDTO.setHisSpecialBatch(String.valueOf(map.get("hisSpecialBatch")));
            scoreLineDTO.setHisUndergraduateBatch(String.valueOf(map.get("hisUndergraduateBatch")));
            scoreLineDTO.setHisSpecialistBatch(String.valueOf(map.get("hisSpecialistBatch")));
            System.out.println(scoreLineDTO.toString());


        }
}
